import Vue from 'vue'
import Vuex from 'vuex'
// import da from 'element-ui/src/locale/lang/da'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    rightList: JSON.parse(sessionStorage.getItem('rightList' || '[]')),
    //保存用户的导航菜单,从session中获取数据,没有就是空数组
    userName: sessionStorage.getItem('username'),
    Icon: sessionStorage.getItem('icon'),
  },
  getters: {},
  mutations: {
    //通过在这里设置一个函数,来修改rightList
    setRightList (state, data) {
      state.rightList = data //新的数据赋值给rightList
      sessionStorage.setItem('rightList', JSON.stringify(data)) //将菜单数据存储到session中

    },
    //登录的用户名
    setUsername (state, data) {
      state.userName = data
      sessionStorage.setItem('username', data)
    },
    //头像地址
    setIcon(state,data){
      state.Icon = data
      sessionStorage.setItem('icon',data)
    }
  }
  ,
  actions: {},
  modules: {}
})
